limsSample.expiredPage = {

    getGridParam: function () {
        let _this = this;
        return {
            type: 'grid',
            id: 'lims-sample-expired-list-grid',
            url: limsSample.baseUrl + '/queries/expired',
            columns: limsSample.getSampleExpiredListColumns(),
            onCellClick: function (field, row) {
                field === 'ext$.batchcode' && Gikam.loadBatchDetailPageV12(row.ext$.batchid, true)
            },
            requestData: {
                // expireFlg_EQ : '0',
                createdByOrgId_EQ: workspace.user.ext$.loginorgid
            },
            readonly: true,
            toolbar: [/*{
                type: 'button',
                text: 'GIKAM.BUTTON.CONFIRM',
                icon: 'submit', color: 'success',
                onClick: function () {
                    let grid = Gikam.getComp('lims-sample-expired-list-grid');
                    let _this = this;
                    let selections = grid.getSelections();
                    if (Gikam.isEmpty(selections)) {
                        Gikam.alert('GIKAM.TIP.CHOOSE_AT_LEAST_ONE_ITEM');
                        return
                    }
                    Gikam.confirm('GIKAM.MODAL.SUBMIT', 'GIKAM.TIP.SUBMIT', function () {
                        let url = limsSample.baseUrl + '/sample/confirm-expired';
                        Gikam.postText(url, Gikam.getJsonWrapper(null, [null, selections])).done(function (req) {
                            grid.refresh();
                            Gikam.getComp('lims-sample-expired-confirmed-list-grid').refresh();
                        })
                    })
                }
            }*/],
            page: true
        }
    },

    getConfirmedGridParam: function () {
        var _this = this;
        return {
            type: 'grid',
            id: 'lims-sample-expired-confirmed-list-grid',
            url: limsSample.baseUrl + '/queries/expired',
            columns: limsSample.getSampleExpiredListColumns(),
            onCellClick: function (field, row) {
                field === 'ext$.batchcode' && Gikam.loadBatchDetailPageV12(row.ext$.batchid, true)
            },
            requestData: {
                expireFlg_EQ: '1'
            },
            readonly: true,
            page: true
        }
    },

    getMainTab: function () {
        var _this = this
        var first = false
        return {
            type: 'tab',
            panels: [{
                title: 'GIKAM.TAB.CONFIRM',
                items: [_this.getGridParam()]
            }, {
                title: 'GIKAM.TAB.CONFIRMED',
                items: [_this.getConfirmedGridParam()]
            }],
            onActived: function (data) {
                var tab = Gikam.getComp('main-tab');
                switch (data.index) {
                    case 0:
                        if (first) {  // 首次加载页面时，不操作
                            Gikam.getAsyncComp('lims-sample-expired-list-grid').done(function (grid) {
                                grid.refresh()
                            })
                        }
                        break
                    case 1:
                        Gikam.getAsyncComp('lims-sample-expired-confirmed-list-grid').done(function (grid) {
                            grid.refresh()
                        })
                        break
                }
                first = true;
            }
        }
    },

    create: function () {
        var _this = this;
        Gikam.create('layout', {
            id: 'lims-sample-search-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                items: [this.getGridParam()]
            }
        });
    },

    init: function () {
        this.create();
    }
};
